package com.neu.controller;

import com.neu.service.UserService;
import com.neu.utils.ResultModel;
import com.neu.vo.UserVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/users")
public class UserController {

    private Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    UserService userService;

    @RequestMapping("/{id}")
    public ResultModel<UserVO> findById(@PathVariable("id") int id) throws Exception {

        System.out.println(0 / 0);

        ResultModel<UserVO> resultModel = new ResultModel<>();
        resultModel.setCode(200);
        resultModel.setMsg("成功");
        resultModel.setData(userService.findById(id));

        logger.error("findById方法被调用了");

        return resultModel;
    }

}
